<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta content="text/html;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta http-equiv ="Pragma" content = "no-cache"/>
	<meta http-equiv="Cache-Control" content="no cache" />
	<meta http-equiv="Expires" content="0" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<meta name="format-detection" content="telephone=no"/>
	<script src="https://cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
	<link href="https://cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="../../plugins/layui/css/layui.css" media="all"/>
	<link rel="stylesheet" type="text/css" href="../../css/fs.css" media="all"/>
	<script type="text/javascript" src="../../plugins/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="../../plugins/home/common.js"></script>
	<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
	<script type="text/javascript" src="../../plugins/layui/layui.js"></script>
	<script type="text/javascript" src="../../plugins/frame/js/fsDict.js"></script>
	<script type="text/javascript" src="../../plugins/frame/js/fs.js"></script>
	<script type="text/javascript" src="../../plugins/frame/js/frame.js"></script>

	<script type="text/javascript" src="../../scripts/home/yunhetong.js"></script>
	<script type="text/javascript" src="../../scripts/home/magerIndcInfo.js"></script>
	<style>
		.laytable-cell-1-11 {
			width: 230px;
			text-align: left;
		}
	</style>
</head>
<body>
<div >
	<div class="layui-fluid">
		<div class="layui-row layui-col-space1">
			<div class="layui-col-md12">
				<div class="layui-form-query">
					<form class="layui-form" id="query_form">
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-mid">管理人名称：</label>
								<div class="layui-input-inline" style="width: 200px;">
									<input type="text" name="custNm" autocomplete="off" class="layui-input"  placeholder="请输入管理人名称"/>
								</div>
							</div>
							<div class="layui-inline">
								<div class="layui-input-inline">
									<button class="layui-btn" type="button" function="query"><i class="layui-icon">&#xe615;</i>查询</button>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div class="layui-col-md12">
				<div class="layui-row grid-demo">
					<div class="layui-col-md12">
						<button class="layui-btn" id="renZheng" function="top" topUrl="/views/magerIndeInfo/add.html" topWidth="600px" isMaximize="1" topHeight="400px" topTitle="管理人认证">
							<i class="layui-icon">&#xe654;</i>管理人认证
						</button>
					<!--	<button class="layui-btn" function="test2" topWidth="600px" isMaximize="0" topHeight="400px" topTitle="管理人信息变更">
							<i class="layui-icon">&#xe654;</i>管理人信息变更
						</button>-->

					<!--	<button class="layui-btn layui-btn-danger" function="submit" url="/magerIndeInfo/delete.shtml" isMutiDml="1" isConfirm="1" confirmMsg="是否确定删除选中的数据？" inputs="custNm:">
							<i class="layui-icon">&#xe640;</i>批量删除
						</button>
						-->
						<!--<button class="layui-btn" function="kfapp">
							<i class="layui-icon">&#xe756;</i>测试
						</button>-->
						<button class="layui-btn" function="refresh" style="display: none" id="refresh">
							<i class="layui-icon">&#x1002;</i>刷新
						</button>
					</div>
					<div class="layui-col-md12">
						<table id="fsDatagrid" lay-filter="fsDatagrid" class="fsDatagrid" isLoad="1" url="/magerIndeInfo/findAllListPage.shtml" isPage="1" sortType="1" defaultForm="query_form" height="full-135" lay-filter="test"></table>

						<div class="fsDatagridCols">
							<p type="numbers" title="序号" fixed="left"/>
							<!--<p checkbox="true"/>-->
							<p field="custNm" title="管理人名称" width="260" sort="true" fixed="left" />
							<p field="certTyp" title="证件类型" width="160" sort="true" templet="#column2Tpl"/>
							<p field="certNo" title="认证号码" width="160" sort="true"/>
						<!--	<p field="caCustId" title="caCustId" width="160" sort="true"/>-->
						<!--	<p field="idenDate" title="认证时间" width="160" sort="true"/>
							<p field="modiDate" title="最近修改时间" width="160" sort="true"/>-->
							<p field="contractNm" title="合同模板管理" width="330" templet="#contractNmTpl"/>
							<p field="magerNm" title="管理人公章" width="330" templet="#magerNmTpl"/>
							<p field="agentNm" title="法定代表人/授权代表章" width="330" templet="#agentNmTpl"/>
							<p field="cancelContractNm" title="作废协议管理" width="330" templet="#cancelContractNmTpl"/>
							<!--<p fixed="right" align="center" width="160" toolbar="#barDemo" title="操作"/>-->
						</div>
						<script type="text/html" id="barDemo">
							<a id="edit" class="layui-btn layui-btn-xs" lay-event="top" topUrl="edit.html" topMode="edit" topWidth="600px" topHeight="400px" isSelect="1" topTitle="编辑信息" inputs="custNm:">编辑</a>
							<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="top" topUrl="edit.html" topMode="readonly" topWidth="600px" topHeight="400px" topTitle="查看" inputs="custNm:">查看</a>
							<a id="del" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="submit" isConfirm="1" url="/app-yunhetong-center/magerIndeInfo/delete.shtml" inputs="custNm:">删除</a>
						</script>
						<script type="text/html" id="column2Tpl">
							{{# if(d.certTyp=='1'){}}
							<span style="color: #5FB878">社会信用代码</span>
							{{#} else if(d.certTyp=='2'){}}
							<span style="color: #5FB878"> 营业执照注册号</span>
							{{#} else if(d.certTyp=='3'){}}
							<span style="color: #5FB878"> 组织机构代码</span>
							{{#} else {}}
							<span style="color: #5FB878"> </span>
							{{#}}}
						</script>
						<script type="text/html" id="contractNmTpl">
							{{# if(d.contractNm==''){}}
								<a class="layui-btn demoMore layui-btn-sm"  onclick="uploadFile('E1','{{d.caCustId}}')" style="float: right"><i class="layui-icon"></i>添加</a>
							{{#} else {}}
								<a href="{{d.contractAdd}}" style="color: #1b6aaa">{{d.contractNm}}</a>&nbsp;&nbsp;
							   <a onclick="deleteTemplate('E2','{{d.caCustId}}')" class="layui-btn layui-btn-sm" style="float: right"><i class="layui-icon"></i>删除</a>
							{{#}}}
						</script>
						<script type="text/html" id="magerNmTpl">
							{{# if(d.magerNm==''){}}
								<a class="layui-btn demoMore layui-btn-sm"  onclick="uploadFile('F1','{{d.caCustId}}')" style="float: right"><i class="layui-icon"></i>添加</a>
							{{#} else {}}
								<a href="{{d.magerAdd}}" style="color: #1b6aaa" download="">{{d.magerNm}}</a>

							   <a onclick="deleteTemplate('F2','{{d.caCustId}}')" class="layui-btn layui-btn-sm" style="float: right"> <i class="layui-icon"></i>删除</a>
							{{#}}}
						</script>
						<script type="text/html" id="agentNmTpl">
							{{# if(d.agentNm==''){}}
<!--
								<a class="layui-btn demoMore" lay-event="faRen"  onclick="uploadFile('G1','{{d.caCustId}}')">添加</a>
-->
								<a class="layui-btn layui-btn-sm" lay-event="faRen"  style="float: right"><i class="layui-icon"></i>添加</a>

							{{#} else {}}
								{{d.agentUserNm}}
							<a class="layui-btn layui-btn-sm" lay-event="faRen" style="float: right" ><i class="layui-icon"></i>编辑</a>
<!--
							   <a onclick="deleteTemplate('G2','{{d.caCustId}}')" class="layui-btn layui-btn-sm"><i class="layui-icon"></i> 编辑</a>
-->
							{{#}}}
						</script>
						<script type="text/html" id="cancelContractNmTpl">
							{{# if(d.cancelContractNm==''){}}
								<a class="layui-btn demoMore layui-btn-sm"  onclick="uploadFile('H1','{{d.caCustId}}')" style="float: right"><i class="layui-icon"></i>添加</a>
							{{#} else {}}
								<a href="{{d.cancelContractAdd}}" style="color: #1b6aaa">{{d.cancelContractNm}}</a>
							   <a onclick="deleteTemplate('H2','{{d.caCustId}}')" class="layui-btn layui-btn-sm" style="float: right"><i class="layui-icon"></i> 删除</a>
							{{#}}}
						</script>
					</div>
				</div>
			</div>
		</div>


	</div>
</div>
<button class="layui-btn demoMore"  id="uploadBtn" style="display: none">添加</button>
<script>
	var uploadType='';//上传类型
	var caCustId='';//上传行的管理员认证id
    var domain=getDomain();
    var renZhengUrl=$("#renZheng").attr('topUrl');
    $("#renZheng").attr('topUrl',domain+renZhengUrl);
    var tableQueryUrl=$("#fsDatagrid").attr('url');
    var token=getLongToken();
    var extsArr='';
    var uploadInst='';//创建一个实例
    var operatorId=getCurrentLoginUser();
    layui.use(['upload','form'], function(){
        var form = layui.form;
        var $ = layui.jquery
            ,upload = layui.upload;
           //同时绑定多个元素，并将属性设定在元素上,限制docx
        uploadInst=upload.render({
                elem: '.demoMore'
                ,url:domain+'/api/upload/one'
                ,accept: 'file' //普通文件
                ,data:{token:token,"operatorId":operatorId,"caCustId":caCustId,"type":uploadType}
                ,auto: true
                // ,exts: 'zip|rar|7z' //只允许上传压缩文件
                ,exts: 'docx' //只允许上传压缩文件
                ,multiple: false
                ,size: 1024 //限制文件大小，单位 KB
                ,before: function(obj){
                    //layer.tips('接口地址：'+ this.url, this.item, {tips: 1});
                    layer.load(); //上传loading

                }
                ,done: function(res, index, upload){
                    console.log(caCustId);
                    var item = this.item;
                    var fileId=res.data.fileId;
                    var fileName=res.data.oriFileName;
                    var fileUrl=res.data.fileUrl;
                console.log(JSON.stringify(res)); //获取当前触发上传的元素，layui 2.1.0 新增
                console.log(JSON.stringify(index)); //获取当前触发上传的元素，layui 2.1.0 新增
                console.log(JSON.stringify(upload)); //获取当前触发上传的元素，layui 2.1.0 新增
                //关闭loading
                layer.closeAll('loading');
				if(res.code==0){
					addTemplate(uploadType,caCustId,fileId,fileName,fileUrl);
				}else{
					messageErrorInfo(res.message);
					return;
				}

                }
                ,error:function(){
               		 layer.closeAll('loading');
                      messageErrorInfo("接口返回异常")
				}
            });

    });
    window.uploadFile= function(type,id){
        uploadType=type;
        caCustId=id;
        if(uploadType=='G1'){
            var param="?caCustId="+caCustId+"&certTyp="+certTyp+"&certNo="+certNo+"&custNm="+custNm+"&mobileNo="+mobileNo+"&crmMagerId="+crmMagerId;
           // var param='';
			var indexDialog=layer.open({
                type: 2,//类型，解析url
                title: '法人信息管理',
                /*            closeBtn: 0, //不显示关闭按钮
                            shadeClose: true,
                            shade: [0],*/
                id: (new Date()).valueOf(), //设定一个id，防止重复弹出 时间戳1280977330748
                maxmin: true, //开启最大化最小化按钮
                area: ['893px', '600px'],
                anim: 2,
                content: ['faRenInfoManager.html'+param, 'auto'], //iframe的url，no代表不显示滚动条
                end: function(){ //此处用于演示

                }
            });
            //弹出即全屏
            layer.full(indexDialog);
		}
        else if(uploadType=='F1'){
            //重载该实例，支持重载全部基础参数
            uploadInst.reload({
                accept: 'images' //只允许上传图片
                ,acceptMime: 'image/*' //只筛选图片
                ,size: 400 //限定大小
                ,exts: 'png' //只允许上传压缩文件
                ,data:{token:token,"operatorId":operatorId,"caCustId":caCustId,"type":uploadType}
            });
        }else{
            uploadInst.reload({
                accept: 'file' //只允许上传图片
                ,size: 1024*10 //限定大小
                ,exts: 'docx' //只允许上传压缩文件
                ,data:{token:token,"operatorId":operatorId,"caCustId":caCustId,"type":uploadType}
            });
		}


        $("#uploadBtn").click();
        //fileupload(type,id)
    }
    layui.fsButton.faRen = function(elem,data,datagrid){
       // alert("测试自定义按钮2"+JSON.stringify(data));
        var caCustId=data.caCustId;
        var agentUserId=data.agentUserId;//法人签署者id
        var certTyp=data.certTyp;
        var certNo=data.certNo;
        var custNm=data.custNm;
        var mobileNo=data.mobileNo;
        var crmMagerId=data.crmMagerId;
        var param="?caCustId="+caCustId+"&certTyp="+certTyp+"&certNo="+certNo+"&custNm="+custNm+"&mobileNo="+mobileNo+"&crmMagerId="+crmMagerId+"&agentUserId="+agentUserId;
        indexDialog=layer.open({
            type: 2,//类型，解析url
            title: '法人信息管理',
            /*            closeBtn: 0, //不显示关闭按钮
                        shadeClose: true,
                        shade: [0],*/
            id: (new Date()).valueOf(), //设定一个id，防止重复弹出 时间戳1280977330748
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            anim: 2,
            content: ['faRenInfoManager.html'+param, 'auto'], //iframe的url，no代表不显示滚动条
            end: function(){ //此处用于演示

            }
        });
        //弹出即全屏
        layer.full(indexDialog);
    }
function closeDialog(){
    messageInfo("操作成功");
    layer.close(indexDialog);
    window.location.reload();
}
function parentReload(){
	$("#refresh").click();
}
    /**
	 * 刷新列表
     * @param datagrid
     */
    layui.fsButton.refresh = function(elem,data,datagrid){
        datagrid.reload();
    }
    layui.fsButton.test2 = function(elem,data,datagrid){
        var length=data.length;
        if(length==0){
            messageInfo("请先选择1条信息")
			return;
		}
        if(length>1){
            messageInfo("1次只能选择1条信息");
            return;
        }
       var caCustId=data[0].caCustId;
        var certTyp=data[0].certTyp;
        var certNo=data[0].certNo;
        var custNm=data[0].custNm;
        var mobileNo=data[0].mobileNo;
        var crmMagerId=data[0].crmMagerId;
       // alert(caCustId+","+certTyp+","+certNo+","+custNm+","+mobileNo+"&crmMagerId="+crmMagerId);
        //iframe窗
        var param="?caCustId="+caCustId+"&certTyp="+certTyp+"&certNo="+certNo+"&custNm="+custNm+"&mobileNo="+mobileNo+"&crmMagerId="+crmMagerId;
        indexDialog=layer.open({
            type: 2,//类型，解析url
            title: '管理人信息变更',
/*            closeBtn: 0, //不显示关闭按钮
            shadeClose: true,
            shade: [0],*/
            id: (new Date()).valueOf(), //设定一个id，防止重复弹出 时间戳1280977330748
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            anim: 2,
            content: ['edit.html'+param, 'no'], //iframe的url，no代表不显示滚动条
            end: function(){ //此处用于演示

            }
        });
        //弹出即全屏
        layer.full(indexDialog);
    }
</script>


<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听行单击事件（单击事件为：rowDouble）
        table.on('row(test)', function(obj){
            var data = obj.data;
            layer.alert(JSON.stringify(data), {
                title: '当前行数据：'
            });
            //标注选中样式
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });

    });
</script>

    </body>
</html>

